//
//  cooperationOrderViewController.m
//  lmq
//
//  Created by 千翼网络科技 on 2017/4/12.
//  Copyright © 2017年 yuanxin. All rights reserved.
//

#import "cooperationOrderViewController.h"
#import "configddd.h"
#import <Masonry/Masonry.h>

#import "ZJScrollPageView.h"
#import "oneViewController.h"
#import "twoViewController.h"
#import "threeViewController.h"
#import "fourViewController.h"

@interface cooperationOrderViewController ()<ZJScrollPageViewDelegate>{

    NSMutableArray *dataArray;
}

@property(strong, nonatomic)NSArray<NSString *> *titles;
@property(strong, nonatomic)NSArray<UIViewController<ZJScrollPageViewChildVcDelegate> *> *childVcs;

@end

@implementation cooperationOrderViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"商家订单";
    [self initView];
}

- (void)initView{

    //必要的设置, 如果没有设置可能导致内容显示不正常
    self.automaticallyAdjustsScrollViewInsets = NO;
    ZJSegmentStyle *style = [[ZJSegmentStyle alloc] init];
    //显示滚动条
    style.showLine = YES;
    // 颜色渐变
    style.gradualChangeTitleColor = YES;
    style.scrollTitle = YES;
    style.autoAdjustTitlesWidth = YES;
    style.adjustCoverOrLineWidth = YES;
    style.selectedTitleColor = [UIColor colorWithRed:6 / 255.0f green:6 / 255.0f blue:6 / 255.0f alpha:1];
    style.scrollLineColor = [UIColor colorWithRed:6 / 255.0f green:6 / 255.0f blue:6 / 255.0f alpha:1];
    style.segmentHeight = 40;
    self.titles = @[@"全部",
                    @"待付款",
                    @"待消费",
                    @"消费完成",
                    ];
    self.childVcs = [self setupChildVc];
    
    // 初始化
    ZJScrollPageView *scrollPageView = [[ZJScrollPageView alloc] initWithFrame:CGRectMake(0, 0, DEF_SCREEN_WIDTH, DEF_SCREEN_HEIGHT - 64.0) segmentStyle:style titles:self.titles parentViewController:self delegate:self];
    [scrollPageView setSelectedIndex:self.index animated:YES];
    scrollPageView.contentView.scrollView.scrollEnabled = YES;
    [self.view addSubview:scrollPageView];
}

#pragma mark ----------------ZJScrollPageViewDelegate---------------------

- (NSInteger)numberOfChildViewControllers {
    
    return self.titles.count;
}

- (NSArray *)setupChildVc {
    
    oneViewController *vc1 = [oneViewController new];
    
    twoViewController *vc2 = [twoViewController new];
    
    threeViewController *vc3 = [threeViewController new];
    
    fourViewController *vc4 = [fourViewController new];
    
    NSArray *childVcs = [NSArray arrayWithObjects:vc1, vc2, vc3, vc4, nil];
    return childVcs;
}

- (UIViewController<ZJScrollPageViewChildVcDelegate> *)childViewController:(UIViewController<ZJScrollPageViewChildVcDelegate> *)reuseViewController forIndex:(NSInteger)index {
    
    UIViewController<ZJScrollPageViewChildVcDelegate> *childVc = reuseViewController;
    
    if (!childVc) {
        
        childVc = self.childVcs[index];
    }
    
    return childVc;
}



@end
